<script setup>

import { StarOutlined, LikeOutlined, MessageOutlined } from '@ant-design/icons-vue';
import {noticeListGet, noticePageGet} from '@/api/noticeApi.js';
import {ref} from 'vue';
import {loading} from '@/utils/loadingUtils.js';

let listData = ref([]);

const pagination = {
  onChange: page => {
    console.log(page);
  },
  pageSize: 3,
};
const actions = [
  {
    icon: StarOutlined,
    text: '156',
  },
  {
    icon: LikeOutlined,
    text: '156',
  },
  {
    icon: MessageOutlined,
    text: '2',
  },
];

// for (let i = 0; i < 23; i++) {
//   listData.push({
//     href: 'https://www.antdv.com/',
//     title: `ant design vue part ${i}`,
//     avatar: 'https://joeschmoe.io/api/v1/random',
//     description:
//         'Ant Design, a design language for background applications, is refined by Ant UED Team.',
//     content:
//         'We supply a series of design principles, practical patterns and high quality design resources (Sketch and Axure), to help people create their product prototypes beautifully and efficiently.',
//   });
// }


async function loadData() {
  listData.value  =await noticeListGet({})
}

loadData()

</script>

<template>

  <a-card>
    <a-spin :spinning="loading" size="large" >
    <a-list  item-layout="vertical" size="large" :pagination="pagination" :data-source="listData">
      <template #renderItem="{ item }">
        <a-list-item key="item.title">
          <template #actions>
          <span v-for="{ icon, text } in actions" :key="icon">
            <component :is="icon" style="margin-right: 8px" />
            {{ text }}
          </span>
          </template>
          <template #extra>
           <div style="width: 150px" v-if="item.files && item.files.length > 0">
             <img

                 alt="logo"
                 :src="item.files[0]"
             />
           </div>
          </template>
          <a-list-item-meta :description="item.description">
            <template #title>
              <a :href="item.href">{{ item.title }}</a>
            </template>
            <template #avatar><a-avatar :src="item.avatar" /></template>
          </a-list-item-meta>
          {{ item.content }}
        </a-list-item>
      </template>
    </a-list>
    </a-spin>
  </a-card>

</template>

<style scoped>

</style>
